variance Function

public function variance(a) result(v)

Function to calculate the variance of a real array

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout), dimension(:) :: a

A real array

Return Value real(kind=wp)

A real variable with the calculated variance


Calls

proc~~variance~~CallsGraph proc~variance variance proc~mean mean proc~variance->proc~mean float float proc~mean->float

Called by

proc~~variance~~CalledByGraph proc~variance variance proc~std std proc~std->proc~variance proc~coefficient_of_variation coefficient_of_variation proc~coefficient_of_variation->proc~std proc~correlation_coefficient correlation_coefficient proc~correlation_coefficient->proc~std

Source Code

    function variance(a) result(v)
!=============================================================================================
!! Function to calculate the variance of a real array
        real(kind=wp),dimension(:),intent(inout) :: a
!! A real array
        real(kind=wp) :: v
!! A real variable with the calculated variance 
        real(kind=wp),dimension(size(a)) :: a2
!
        a2=a**2;
        v=mean(a2)-(mean(a))**2;
!
    end function variance